import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
export default ({
  state: {
    menusList : [],
    permsList : [],
    hasRoute: false,
    // 标签页
    tabsValue: "Index",
    tabs: [
      {
        title: '首页',
        name: 'Index',
      },
    ],
  },
  mutations: {
    RESET:(state) => {
      state.token = undefined;
      state.menusList = [],
      state.permsList = [],
      state.hasRoute = false,
      state.tabsValue = "Index",
      state.tabs =  [
        {
          title: '首页',
          name: 'Index',
        },
      ]
   
    },
    SET_MENUSLIST:(state, menusList) => {
      state.menusList = menusList;
    },
    SET_PERMSLIST(state, permsList) {
      state.permsList = permsList;
    },
    SET_HASROUTE(state, hasRoute) {
      state.hasRoute = hasRoute;
    },
    SET_EDITABLETABS(state, tab) {
      let index = state.tabs.findIndex(item => item.name === tab.name)
      if(index == -1) {
        state.tabs.push({
          title: tab.title,
          name: tab.name,
        })
      }
      state.tabsValue = tab.name
    }
  
  },
  actions: {
  },
  modules: {
  }
})
